from django.db import models

# Create your models here.

from BookContent.models import BookPageContent

'''
"COMMENT_TIME": "2020-07-07 10:33:29",
        "FIRSTNICKNAME": "网友1271622",
        "IS_PRAISE": null,
        "TAG":"",
        "COMMENT": "",
        "PRAISE_NUM": 0,
        "CANDELETE": 1,
        "HEADIMGURL": "http://img2.imgtn.bdimg.com/it/u=2659658743,1944621503&fm=26&gp=0.jpg",
        "SECONDNICKNAME": null

'''


class DetailComment(models.Model):
    id = models.AutoField(primary_key=True)
    COMMENT_TIME = models.DateTimeField(auto_now_add =True)
    FIRSTNICKNAME = models.CharField(max_length=80, default='匿名用户')
    IS_PRAISE = models.BooleanField(default=True)
    TAG = models.CharField(max_length=80)
    COMMENT = models.TextField(verbose_name='评论名称')
    PRAISE_NUM = models.IntegerField(verbose_name='点赞量', default=0)
    CANDELETE = models.IntegerField(verbose_name='是否可删除', default=1)
    # HEADIMGURL = models.ImageField(upload_to='scoreimgs/comment/', default='scoreimgs/comment/default.png', blank=True,
    #                                null=True)  # 允许空

    Comment_DetailPage = models.ForeignKey(BookPageContent, related_name='comments', on_delete=models.CASCADE)

    class Meta:
        ordering = ('COMMENT_TIME',)
        verbose_name = '评论'
        verbose_name_plural = verbose_name
    def __str__(self):
        return 'Comments by {} on {}'.format(self.FIRSTNICKNAME, self.COMMENT_TIME)
